import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:url_launcher/url_launcher.dart';

import '../../common.dart';

Widget isdata() {
  return Container(
    child: Image.asset(
      'static/web/htuishi.png',
      width: 128,
      fit: BoxFit.fitWidth,
    ),
  );
}

RxList resList = [].obs;
String wantId = '';

showTost(text) {
  Get.dialog(
    barrierColor: Colors.transparent,
    barrierDismissible: false,
    Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Container(
          alignment: Alignment.center,
          width: 130,
          height: 100,
          decoration: BoxDecoration(
            color: Color(0X83000000),
            borderRadius: BorderRadius.circular(15),
          ),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              CircularProgressIndicator(backgroundColor: Color(0XFFffffff)),
              Text(
                text,
                style: TextStyle(fontSize: 16, color: Color(0XFFFFFFFF)),
              ),
            ],
          ),
        ),
      ],
    ),
  );
}

Timer? _timer;

class MarketList extends StatefulWidget {
  @override
  State<MarketList> createState() => _HomePageState();
}

late TextEditingController _controller;
late TextEditingController controller;
late TextEditingController controller1;
late TextEditingController controller2;
RxInt num = 1.obs;
RxInt wnum = 1.obs;
RxInt tindex = (-1).obs;
RxMap selItem = {}.obs;
final spacing = 12; // 间距
RxMap info = {}.obs;

class _HomePageState extends State<MarketList> {
  final RxInt _index = 0.obs;
  String? id = Get.parameters['id'];
  RxInt page = 1.obs;
  RxList list = [].obs;
  RxBool isLike = false.obs;

  RxList items =
      [
        {'text': "寄售", "index": 0},
        {'text': "", "index": 1},
        {'text': "", "index": 2},
      ].obs;

  getList(url) {
    getData(
      url: url,
      data: {"page": '$page', "per_page": '20', "product_id": '$id'},
    ).then((res) {
      if (res.length > 0) {
        if (_index.value == 1) {
          for (var i = 0; i < res['list'].length; i++) {
            res['list'][i]['skutotal'] =
                res['list'][i]['sku_total'] - res['list'][i]['ok_count'];

            res['list'][i]['allskutotal'] =
                (res['list'][i]['sku_total'] - res['list'][i]['ok_count']) *
                res['list'][i]['product_money_price'] /
                100;

            res['list'][i]['numall'] =
                res['list'][i]['ok_count'] / res['list'][i]['sku_total'];
          }
        }

        list.value = res['list'];

        info.value = res['info'];

        if (res['info']['is_want'] == 1) {
          items[1]['text'] = '委托';
        }
        if (res['info']['is_bidding'] == 1) {
          items[2]['text'] = '竞价';
        }
      }
    });
  }

  getLike() {
    getData(url: '/market/likeStatus', data: {"product_id": '$id'}).then((res) {
      isLike.value = res['is_like'];
    });
  }

  goTimer(number) {
    getData(url: '/resale/checkNumber', data: {"number": '$number'}).then((
      res,
    ) {
      if (res['status'] == 1) {
        _timer?.cancel();
        _timer = null;
        if (kIsWeb) {
          final uur = Uri.parse('${res['pay_url']}');
          launchUrl(uur, webOnlyWindowName: '_self');
        } else {
          toNamed('/webview?url=${res['pay_url']}&app=1&back=suu');
        }
      }

      if (res['status'] == 0) {
        _timer?.cancel();
        _timer = null;

        _timer = Timer.periodic(Duration(seconds: 1), (timer) {
          goTimer(number);
        });
      }

      if (res['status'] == 2) {
        Get.back();

        showTost('下单失败');
        _timer?.cancel();
        _timer = null;
      }
    });
  }

  @override
  void initState() {
    super.initState();
    _controller = TextEditingController();
    controller = TextEditingController();
    controller1 = TextEditingController();
    controller2 = TextEditingController();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      getList('/market/resales');
      getLike();
    });
  }

  @override
  void dispose() {
    _timer?.cancel();
    _controller.dispose();
    controller.dispose();
    controller2.dispose();
    controller1.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    con(context);
    final screenWidth = MediaQuery.of(context).size.width;

    final itemWidth = (screenWidth - spacing) / 2;

    return Scaffold(
      body: Column(
        children: [
          Expanded(
            child: ListView(
              padding: EdgeInsets.only(top: 0),
              children: [
                Stack(
                  children: [
                    Container(alignment: Alignment.topLeft, height: 380),
                    Positioned(
                      child: Obx(
                        () => Image.network(
                          '${info['thumb']}',
                          width: screenWidth,
                          height: 350,
                          fit: BoxFit.fill,
                          errorBuilder: (context, error, stackTrace) {
                            return SizedBox(width: 60);
                          },
                        ),
                      ),
                    ),
                    Positioned(
                      top: 40,
                      left: 15,
                      child: GestureDetector(
                        onTap: () => {back()},
                        child: Icon(Icons.arrow_back_ios, color: Colors.black),
                      ),
                    ),
                    Positioned(
                      top: 40,
                      right: 60,
                      child: GestureDetector(
                        onTap:
                            () => {
                              toNamed(
                                '/web_tabs/market/transaction_record?id=$id&title=${info['title']}',
                              ),
                            },
                        child: Image.asset(
                          'static/web/dianshi.png',
                          width: 28,
                          fit: BoxFit.fitWidth,
                        ),
                      ),
                    ),
                    Positioned(
                      top: 40,
                      right: 15,
                      child: GestureDetector(
                        onTap: () {
                          if (isLike.value) {
                            postData(
                              url: '/market/unLikeGoods',
                              data: {'product_id': '$id'},
                            ).then((res) {
                              if (res != null) {
                                isLike.value = false;
                              }
                            });
                          } else {
                            postData(
                              url: '/market/likeGoods',
                              data: {'product_id': '$id'},
                            ).then((res) {
                              if (res != null) {
                                isLike.value = true;
                              }
                            });
                          }
                        },
                        child: Obx(
                          () => Image.asset(
                            isLike.value
                                ? 'static/web/haixin.png'
                                : 'static/web/baixin.png',
                            width: 28,
                            fit: BoxFit.fitWidth,
                          ),
                        ),
                      ),
                    ),
                    Positioned(
                      right: 15,
                      bottom: 0,
                      child: Container(
                        padding: EdgeInsets.symmetric(
                          horizontal: 15,
                          vertical: 10,
                        ),
                        decoration: BoxDecoration(
                          color: Color(0XFF0F172B),
                          borderRadius: BorderRadius.circular(16),
                        ),
                        child: Column(
                          crossAxisAlignment: CrossAxisAlignment.start,
                          children: [
                            Text(
                              '限价',
                              style: TextStyle(
                                fontSize: 11,
                                color: Color(0XFFFFFFFF),
                              ),
                            ),
                            Row(
                              children: [
                                Obx(
                                  () =>
                                      info.isNotEmpty
                                          ? Text(
                                            '${info['examine_max_ratio'] / 100}',
                                            style: TextStyle(
                                              fontSize: 18,
                                              color: Color(0XFFFFFFFF),
                                            ),
                                          )
                                          : Text(''),
                                ),
                                Text(
                                  '元',
                                  style: TextStyle(
                                    fontSize: 11,
                                    color: Color(0XFFFFFFFF),
                                  ),
                                ),
                              ],
                            ),
                          ],
                        ),
                      ),
                    ),
                  ],
                ),

                Transform.translate(
                  offset: Offset(0, -10),
                  child: Padding(
                    padding: EdgeInsets.only(left: 15),
                    child: Obx(
                      () => Text(
                        '${info['title']}',
                        style: TextStyle(
                          fontSize: 18,
                          color: Color(0XFF0F172B),
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ),
                ),
                Transform.translate(
                  offset: Offset(0, -5),
                  child: Padding(
                    padding: EdgeInsets.only(left: 15),
                    child: Obx(
                      () => Text(
                        '限量${info['sell_num']}份，流通${info['release_num']}份',
                        style: TextStyle(
                          fontSize: 14,
                          color: Color(0XFF1F0584),
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ),
                ),
                SizedBox(height: 25),
                Padding(
                  padding: EdgeInsets.symmetric(horizontal: 15),
                  child: Obx(
                    () => Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        if (info.isNotEmpty)
                          for (var item in items)
                            Expanded(
                              child: GestureDetector(
                                onTap: () {
                                  if (item['index'] == 0) {
                                    getList('/market/resales');
                                    _index.value = item['index'];
                                  } else if (item['index'] == 1) {
                                    if (info['is_want'] == 1) {
                                      getList('/market/want');
                                      _index.value = item['index'];
                                    }
                                  } else {
                                    if (info['is_bidding'] == 1) {
                                      getList('/market/bidding');
                                      _index.value = item['index'];
                                    }
                                  }
                                },
                                child: Container(
                                  padding: EdgeInsets.only(bottom: 8),
                                  alignment: Alignment.center,
                                  decoration: BoxDecoration(
                                    border: Border(
                                      bottom: BorderSide(
                                        width: 3,
                                        color:
                                            _index.value == item['index']
                                                ? Color(0XFF0F172B)
                                                : Color(0XFFF8F9FD),
                                      ),
                                    ),
                                  ),
                                  child: Text(
                                    item['index'] == 0
                                        ? '${item['text']} ${info['count_resale']}'
                                        : item['index'] == 1 &&
                                            info['is_want'] == 1
                                        ? '${item['text']} ${info['count_want']}'
                                        : item['index'] == 2 &&
                                            info['is_bidding'] == 1
                                        ? '${item['text']} ${info['count_bidding']}'
                                        : '',
                                    style: TextStyle(
                                      fontSize: 14,
                                      color:
                                          _index.value == item['index']
                                              ? Color(0XFF0F172B)
                                              : Color(0XFF999999),
                                    ),
                                  ),
                                ),
                              ),
                            ),
                      ],
                    ),
                  ),
                ),
                SizedBox(height: 15),

                //寄售
                Obx(
                  () =>
                      _index.value == 0
                          ? Column(
                            children: [
                              if (list.isEmpty) isdata(),
                              for (var item in list.asMap().entries)
                                GestureDetector(
                                  onTap:
                                      () => {
                                        toNamed(
                                          '/web_tabs/market/market_detail?uuid=${item.value['uuid']}&id=${item.value['id']}',
                                        ),
                                      },
                                  child: Container(
                                    height: 70,
                                    margin: EdgeInsets.symmetric(
                                      horizontal: 15,
                                      vertical: 5,
                                    ),
                                    decoration: BoxDecoration(
                                      borderRadius: BorderRadius.circular(10),
                                      color: Color(0XFFF8F9FD),
                                    ),
                                    child: Row(
                                      children: [
                                        Stack(
                                          children: [
                                            ClipRRect(
                                              borderRadius: BorderRadius.only(
                                                topLeft: Radius.circular(10),
                                                bottomLeft: Radius.circular(10),
                                              ),
                                              child: Image.network(
                                                '${item.value['thumb']}',
                                                width: 70,
                                                height: 70,
                                                fit: BoxFit.fill,
                                                errorBuilder: (
                                                  context,
                                                  error,
                                                  stackTrace,
                                                ) {
                                                  return SizedBox(width: 70);
                                                },
                                              ),
                                            ),
                                            if (item.value['status'] == 0)
                                              Positioned(
                                                bottom: 0,
                                                right: 0,
                                                left: 0,
                                                child: Container(
                                                  height: 21,
                                                  alignment: Alignment.center,
                                                  decoration: BoxDecoration(
                                                    color: Color.fromRGBO(
                                                      0,
                                                      0,
                                                      0,
                                                      128,
                                                    ),
                                                    borderRadius:
                                                        BorderRadius.only(
                                                          bottomLeft:
                                                              Radius.circular(
                                                                10,
                                                              ),
                                                        ),
                                                  ),
                                                  child: Text(
                                                    '支付中',
                                                    style: TextStyle(
                                                      fontSize: 12,
                                                      color: Color(0XFFFFFFFF),
                                                    ),
                                                  ),
                                                ),
                                              ),
                                            if (item.value['status'] == 5)
                                              Positioned(
                                                bottom: 0,
                                                right: 0,
                                                left: 0,
                                                child: Container(
                                                  height: 21,
                                                  alignment: Alignment.center,
                                                  decoration: BoxDecoration(
                                                    color: Color.fromRGBO(
                                                      0,
                                                      0,
                                                      0,
                                                      128,
                                                    ),
                                                    borderRadius:
                                                        BorderRadius.only(
                                                          bottomLeft:
                                                              Radius.circular(
                                                                10,
                                                              ),
                                                        ),
                                                  ),
                                                  child: Text(
                                                    '${item.value['status_value']}',
                                                    style: TextStyle(
                                                      fontSize: 12,
                                                      color: Color(0XFFFFFFFF),
                                                    ),
                                                  ),
                                                ),
                                              ),
                                          ],
                                        ),
                                        SizedBox(width: 10),
                                        Column(
                                          crossAxisAlignment:
                                              CrossAxisAlignment.start,
                                          mainAxisAlignment:
                                              MainAxisAlignment.center,
                                          children: [
                                            Text(
                                              '${item.value['title']}',
                                              style: TextStyle(
                                                fontSize: 14,
                                                color: Color(0XFF0F172B),
                                              ),
                                            ),
                                            Text(
                                              '#${hao('${item.value['nftId']}')}/${info['sell_num']}',
                                              style: TextStyle(
                                                fontSize: 12,
                                                color: Color(0XFF999999),
                                              ),
                                            ),
                                            SizedBox(height: 10),
                                            Container(
                                              padding: EdgeInsets.symmetric(
                                                horizontal: 3,
                                              ),
                                              decoration: BoxDecoration(
                                                borderRadius:
                                                    BorderRadius.circular(3),
                                                color: Color(0XFF0F172B),
                                              ),
                                              child: Text(
                                                '汇',
                                                style: TextStyle(
                                                  fontSize: 9,
                                                  color: Color(0XFFFFFFFF),
                                                ),
                                              ),
                                            ),
                                          ],
                                        ),
                                        Expanded(child: SizedBox()),
                                        Text(
                                          '￥',
                                          style: TextStyle(
                                            fontSize: 11,
                                            color: Color(0XFF0F172B),
                                          ),
                                        ),
                                        Text(
                                          '${item.value['money_price']}',
                                          style: TextStyle(
                                            fontSize: 16,
                                            color: Color(0XFF0F172B),
                                            fontWeight: FontWeight.bold,
                                          ),
                                        ),
                                        SizedBox(width: 15),
                                      ],
                                    ),
                                  ),
                                ),
                            ],
                          )
                          : _index.value == 1
                          ? Column(
                            children: [
                              if (list.isEmpty)
                                Container(
                                  margin: EdgeInsets.only(top: 40),
                                  child: Text(
                                    '暂无委托订单',
                                    style: TextStyle(
                                      fontSize: 16,
                                      color: Color(0XFF999999),
                                    ),
                                  ),
                                ),
                              for (var item in list.asMap().entries)
                                GestureDetector(
                                  onTap: () {
                                    return;
                                    //自动委托不用接
                                    getData(
                                      url: '/packages/sku_list',
                                      data: {
                                        "product_id": '$id',
                                        "per_page": "999",
                                        'page': '1',
                                      },
                                    ).then((res) {
                                      final wantId = item.value['id'];

                                      resList.value = res['list'];
                                      tindex.value = -1;
                                      selItem.value = {};
                                      Get.bottomSheet(
                                        isScrollControlled: true,
                                        Container(
                                          height: 210,
                                          padding: EdgeInsets.symmetric(
                                            horizontal: 15,
                                          ),
                                          child: Column(
                                            children: [
                                              SizedBox(height: 20),
                                              Row(
                                                mainAxisAlignment:
                                                    MainAxisAlignment
                                                        .spaceBetween,
                                                children: [
                                                  Column(
                                                    crossAxisAlignment:
                                                        CrossAxisAlignment
                                                            .start,
                                                    children: [
                                                      Text(
                                                        '目前最高竞价',
                                                        style: TextStyle(
                                                          fontSize: 14,
                                                          color: Color(
                                                            0XFF999999,
                                                          ),
                                                        ),
                                                      ),
                                                      Row(
                                                        children: [
                                                          Text(
                                                            '￥',
                                                            style: TextStyle(
                                                              fontSize: 15,
                                                              color: Color(
                                                                0XFF0F172B,
                                                              ),
                                                            ),
                                                          ),
                                                          Text(
                                                            '${info['examine_max_ratio'] / 100}',
                                                            style: TextStyle(
                                                              fontSize: 23,
                                                              color: Color(
                                                                0XFF0F172B,
                                                              ),
                                                              fontWeight:
                                                                  FontWeight
                                                                      .bold,
                                                            ),
                                                          ),
                                                        ],
                                                      ),
                                                    ],
                                                  ),
                                                  GestureDetector(
                                                    onTap: () {
                                                      Get.back();
                                                    },
                                                    child: Image.asset(
                                                      'static/close.png',
                                                      width: 18,
                                                      fit: BoxFit.fitWidth,
                                                    ),
                                                  ),
                                                ],
                                              ),
                                              Divider(
                                                color: Color(0XFFDDDDDD),
                                                height: 30,
                                              ),

                                              Row(
                                                children: [
                                                  Text(
                                                    '${info['title']}',
                                                    style: TextStyle(
                                                      fontSize: 16,
                                                      color: Color(0XFF0F172B),
                                                    ),
                                                  ),
                                                  Text(
                                                    '(拥有${res['list'].length}份)',
                                                    style: TextStyle(
                                                      fontSize: 14,
                                                      color: Color(0XFF999999),
                                                    ),
                                                  ),
                                                ],
                                              ),
                                              Expanded(
                                                child: SizedBox(),
                                                //ListView(
                                                //   padding: EdgeInsets.symmetric(
                                                //       vertical: 15),
                                                //   children: [

                                                //     Lises(itemWidth,'nock')
                                                //   ],
                                                //)
                                              ),
                                              GestureDetector(
                                                onTap: () {
                                                  Get.back();
                                                  Get.dialog(
                                                    AlertDialog(
                                                      backgroundColor:
                                                          Colors.transparent,
                                                      shape: RoundedRectangleBorder(
                                                        borderRadius:
                                                            BorderRadius.circular(
                                                              5,
                                                            ),
                                                      ),
                                                      content: Stack(
                                                        children: [
                                                          Image.asset(
                                                            'static/tan.png',
                                                            width: 255,
                                                            fit:
                                                                BoxFit.fitWidth,
                                                          ),
                                                          Positioned(
                                                            top: 50,
                                                            right: 0,
                                                            left: 0,
                                                            child: Column(
                                                              children: [
                                                                SizedBox(
                                                                  height: 30,
                                                                ),
                                                                Text(
                                                                  '请输入交易密码',
                                                                  style: TextStyle(
                                                                    fontSize:
                                                                        24,
                                                                    color: Color(
                                                                      0XFF0F172B,
                                                                    ),
                                                                  ),
                                                                ),
                                                                SizedBox(
                                                                  height: 30,
                                                                ),
                                                                Container(
                                                                  margin:
                                                                      EdgeInsets.symmetric(
                                                                        horizontal:
                                                                            30,
                                                                      ),
                                                                  decoration: BoxDecoration(
                                                                    color: Color(
                                                                      0XFFF8F9FD,
                                                                    ),
                                                                    borderRadius:
                                                                        BorderRadius.circular(
                                                                          10,
                                                                        ),
                                                                  ),
                                                                  child: TextField(
                                                                    obscureText:
                                                                        true,
                                                                    controller:
                                                                        controller2,
                                                                    style: TextStyle(
                                                                      fontSize:
                                                                          15,
                                                                    ),
                                                                    decoration: InputDecoration(
                                                                      isCollapsed:
                                                                          true, //设置高度
                                                                      contentPadding:
                                                                          EdgeInsets.all(
                                                                            15,
                                                                          ),
                                                                      hintStyle: TextStyle(
                                                                        color: Color(
                                                                          0xff999999,
                                                                        ),
                                                                      ),
                                                                      border:
                                                                          InputBorder
                                                                              .none, // 隐藏输入框默认边框
                                                                      hintText:
                                                                          '输入交易密码', // 提示文本
                                                                    ),
                                                                  ),
                                                                ),
                                                                SizedBox(
                                                                  height: 30,
                                                                ),
                                                                GestureDetector(
                                                                  onTap: () {
                                                                    if (controller2
                                                                        .text
                                                                        .isNotEmpty) {
                                                                      postData(
                                                                        url:
                                                                            '/want/getWant',
                                                                        data: {
                                                                          "product_id":
                                                                              '$id',
                                                                          "want_id":
                                                                              "${item.value['id']}",
                                                                          "level2password":
                                                                              controller2.text,
                                                                        },
                                                                      ).then((
                                                                        res,
                                                                      ) {
                                                                        if (res !=
                                                                            null) {
                                                                          Get.back();
                                                                          showTost(
                                                                            '出售成功',
                                                                          );
                                                                          Timer(
                                                                            Duration(
                                                                              milliseconds:
                                                                                  1000,
                                                                            ),
                                                                            () {
                                                                              list.value = [];
                                                                              getList(
                                                                                '/market/want',
                                                                              );
                                                                            },
                                                                          );
                                                                        }
                                                                      });
                                                                    } else {
                                                                      showTost(
                                                                        '输入交易密码',
                                                                      );
                                                                    }
                                                                  },
                                                                  child: Container(
                                                                    width: 210,
                                                                    height: 45,
                                                                    decoration: BoxDecoration(
                                                                      color: Color(
                                                                        0XFF0F172B,
                                                                      ),
                                                                      borderRadius:
                                                                          BorderRadius.circular(
                                                                            45,
                                                                          ),
                                                                    ),
                                                                    alignment:
                                                                        Alignment
                                                                            .center,
                                                                    child: Text(
                                                                      '确认',
                                                                      style: TextStyle(
                                                                        fontSize:
                                                                            18,
                                                                        color: Color(
                                                                          0XFFFFFFFF,
                                                                        ),
                                                                      ),
                                                                    ),
                                                                  ),
                                                                ),
                                                                SizedBox(
                                                                  height: 20,
                                                                ),
                                                                GestureDetector(
                                                                  onTap: () {
                                                                    Get.back();
                                                                  },
                                                                  child: Text(
                                                                    '取消',
                                                                    style: TextStyle(
                                                                      fontSize:
                                                                          18,
                                                                      color: Color(
                                                                        0XFF0F172B,
                                                                      ),
                                                                    ),
                                                                  ),
                                                                ),
                                                              ],
                                                            ),
                                                          ),
                                                        ],
                                                      ),
                                                    ),
                                                  );
                                                },
                                                child: Container(
                                                  margin: EdgeInsets.symmetric(
                                                    vertical: 10,
                                                  ),
                                                  decoration: BoxDecoration(
                                                    color: Color(0XFF0F172B),
                                                    borderRadius:
                                                        BorderRadius.circular(
                                                          50,
                                                        ),
                                                  ),
                                                  height: 50,
                                                  alignment: Alignment.center,
                                                  child: Text(
                                                    '立即出售',
                                                    style: TextStyle(
                                                      fontSize: 16,
                                                      color: Color(0XFFFFFFFF),
                                                    ),
                                                  ),
                                                ),
                                              ),
                                            ],
                                          ),
                                        ),
                                        shape: RoundedRectangleBorder(
                                          // 圆角设置:ml-citation{ref="7" data="citationList"}
                                          borderRadius: BorderRadius.vertical(
                                            top: Radius.circular(15),
                                          ),
                                        ),
                                        backgroundColor: Colors.white,
                                      );
                                    });
                                  },
                                  child: Container(
                                    height: 70,
                                    margin: EdgeInsets.only(
                                      left: 15,
                                      right: 15,
                                      bottom: 15,
                                    ),
                                    decoration: BoxDecoration(
                                      borderRadius: BorderRadius.circular(10),
                                      color: Color(0XFFF8F9FD),
                                    ),
                                    child: Row(
                                      children: [
                                        ClipRRect(
                                          borderRadius: BorderRadius.only(
                                            topLeft: Radius.circular(10),
                                            bottomLeft: Radius.circular(10),
                                          ),
                                          child: Image.network(
                                            '${info['thumb']}',
                                            width: 70,
                                            height: 70,
                                            fit: BoxFit.fill,
                                            errorBuilder: (
                                              context,
                                              error,
                                              stackTrace,
                                            ) {
                                              return SizedBox(width: 60);
                                            },
                                          ),
                                        ),
                                        SizedBox(width: 10),
                                        Expanded(
                                          child: Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.spaceBetween,
                                            children: [
                                              Column(
                                                crossAxisAlignment:
                                                    CrossAxisAlignment.start,
                                                mainAxisAlignment:
                                                    MainAxisAlignment.center,
                                                children: [
                                                  Row(
                                                    children: [
                                                      Text(
                                                        '${item.value['title']}',
                                                        style: TextStyle(
                                                          fontSize: 14,
                                                          color: Color(
                                                            0XFF0F172B,
                                                          ),
                                                        ),
                                                      ),
                                                      if (item.value['is_my'] ==
                                                          true)
                                                        Container(
                                                          margin:
                                                              EdgeInsets.only(
                                                                left: 5,
                                                              ),
                                                          padding:
                                                              EdgeInsets.symmetric(
                                                                horizontal: 5,
                                                                vertical: 3,
                                                              ),
                                                          decoration: BoxDecoration(
                                                            color: Color(
                                                              0XFF542AFF,
                                                            ),
                                                            borderRadius:
                                                                BorderRadius.circular(
                                                                  4,
                                                                ),
                                                          ),
                                                          child: Text(
                                                            '我的',
                                                            style: TextStyle(
                                                              fontSize: 11,
                                                              color: Color(
                                                                0XFFFFFFFF,
                                                              ),
                                                            ),
                                                          ),
                                                        ),
                                                    ],
                                                  ),
                                                  SizedBox(height: 10),
                                                  Row(
                                                    children: [
                                                      Container(
                                                        padding:
                                                            EdgeInsets.symmetric(
                                                              horizontal: 3,
                                                            ),
                                                        decoration: BoxDecoration(
                                                          borderRadius:
                                                              BorderRadius.circular(
                                                                3,
                                                              ),
                                                          color: Color(
                                                            0XFF0F172B,
                                                          ),
                                                        ),
                                                        child: Text(
                                                          '汇',
                                                          style: TextStyle(
                                                            fontSize: 9,
                                                            color: Color(
                                                              0XFFFFFFFF,
                                                            ),
                                                          ),
                                                        ),
                                                      ),
                                                      SizedBox(width: 10),
                                                      Stack(
                                                        children: [
                                                          Container(
                                                            width: 40,
                                                            child: LinearProgressIndicator(
                                                              minHeight: 15,
                                                              borderRadius:
                                                                  BorderRadius.circular(
                                                                    3,
                                                                  ),
                                                              value:
                                                                  item.value['numall'] ??
                                                                  0,
                                                              // 0.5, // 进度值，范围从0.0到1.0
                                                              backgroundColor:
                                                                  Color(
                                                                    0XFF0F172B,
                                                                  ), // 背景颜色
                                                              valueColor:
                                                                  AlwaysStoppedAnimation<
                                                                    Color
                                                                  >(
                                                                    Color(
                                                                      0XFF542AFF,
                                                                    ),
                                                                  ), // 进度条颜色
                                                            ),
                                                          ),
                                                          Positioned(
                                                            left: 0,
                                                            right: 0,
                                                            child: Align(
                                                              child: Text(
                                                                '${item.value['ok_count'] ?? 0}/${item.value['sku_total'] ?? 0}',
                                                                style: TextStyle(
                                                                  fontSize: 12,
                                                                  color: Color(
                                                                    0XFFFFFFFF,
                                                                  ),
                                                                ),
                                                              ),
                                                            ),
                                                          ),
                                                        ],
                                                      ),
                                                      item.value['is_my'] ==
                                                                  true &&
                                                              item.value['up'] !=
                                                                  1
                                                          ? GestureDetector(
                                                            onTap:
                                                                () => {
                                                                  Get.dialog(
                                                                    AlertDialog(
                                                                      backgroundColor:
                                                                          Colors
                                                                              .transparent,
                                                                      shape: RoundedRectangleBorder(
                                                                        borderRadius:
                                                                            BorderRadius.circular(
                                                                              5,
                                                                            ),
                                                                      ),
                                                                      content: Stack(
                                                                        children: [
                                                                          Image.asset(
                                                                            'static/tan.png',
                                                                            width:
                                                                                230,
                                                                            fit:
                                                                                BoxFit.fitWidth,
                                                                          ),
                                                                          Positioned(
                                                                            top:
                                                                                50,
                                                                            right:
                                                                                0,
                                                                            left:
                                                                                0,
                                                                            child: Column(
                                                                              children: [
                                                                                SizedBox(
                                                                                  height:
                                                                                      20,
                                                                                ),
                                                                                Text(
                                                                                  '委托置顶',
                                                                                  style: TextStyle(
                                                                                    fontSize:
                                                                                        24,
                                                                                    color: Color(
                                                                                      0XFF0F172B,
                                                                                    ),
                                                                                    fontWeight:
                                                                                        FontWeight.bold,
                                                                                  ),
                                                                                ),
                                                                                SizedBox(
                                                                                  height:
                                                                                      20,
                                                                                ),
                                                                                Text(
                                                                                  '置顶消耗',
                                                                                  style: TextStyle(
                                                                                    fontSize:
                                                                                        12,
                                                                                    color: Color(
                                                                                      0XFF0F172B,
                                                                                    ),
                                                                                  ),
                                                                                ),
                                                                                SizedBox(
                                                                                  height:
                                                                                      10,
                                                                                ),
                                                                                info['want_up_num'] ==
                                                                                        0
                                                                                    ? Text(
                                                                                      '无需消耗',
                                                                                      style: TextStyle(
                                                                                        fontSize:
                                                                                            14,
                                                                                        color: Color(
                                                                                          0XFF542AFF,
                                                                                        ),
                                                                                      ),
                                                                                    )
                                                                                    : Text(
                                                                                      '${info['want_up_title']} *${info['want_up_num']}',
                                                                                      style: TextStyle(
                                                                                        fontSize:
                                                                                            14,
                                                                                        color: Color(
                                                                                          0XFF542AFF,
                                                                                        ),
                                                                                      ),
                                                                                    ),
                                                                                SizedBox(
                                                                                  height:
                                                                                      30,
                                                                                ),
                                                                                GestureDetector(
                                                                                  onTap: () {
                                                                                    postData(
                                                                                      url:
                                                                                          '/want/up',
                                                                                      data: {
                                                                                        "id":
                                                                                            '${item.value['id']}',
                                                                                      },
                                                                                    ).then(
                                                                                      (
                                                                                        res,
                                                                                      ) {
                                                                                        if (res !=
                                                                                            null) {
                                                                                          Get.back();
                                                                                          getList(
                                                                                            '/market/want',
                                                                                          );
                                                                                        }
                                                                                      },
                                                                                    );
                                                                                  },
                                                                                  child: Container(
                                                                                    width:
                                                                                        200,
                                                                                    height:
                                                                                        45,
                                                                                    decoration: BoxDecoration(
                                                                                      color: Color(
                                                                                        0XFF0F172B,
                                                                                      ),
                                                                                      borderRadius: BorderRadius.circular(
                                                                                        45,
                                                                                      ),
                                                                                    ),
                                                                                    alignment:
                                                                                        Alignment.center,
                                                                                    child: Text(
                                                                                      '确认',
                                                                                      style: TextStyle(
                                                                                        fontSize:
                                                                                            18,
                                                                                        color: Color(
                                                                                          0XFFFFFFFF,
                                                                                        ),
                                                                                      ),
                                                                                    ),
                                                                                  ),
                                                                                ),
                                                                                SizedBox(
                                                                                  height:
                                                                                      30,
                                                                                ),
                                                                                GestureDetector(
                                                                                  onTap: () {
                                                                                    Get.back();
                                                                                  },
                                                                                  child: Text(
                                                                                    '取消',
                                                                                    style: TextStyle(
                                                                                      fontSize:
                                                                                          18,
                                                                                      color: Color(
                                                                                        0XFF0F172B,
                                                                                      ),
                                                                                    ),
                                                                                  ),
                                                                                ),
                                                                              ],
                                                                            ),
                                                                          ),
                                                                        ],
                                                                      ),
                                                                    ),
                                                                  ),
                                                                },
                                                            child: Container(
                                                              margin:
                                                                  EdgeInsets.only(
                                                                    left: 10,
                                                                  ),
                                                              padding:
                                                                  EdgeInsets.symmetric(
                                                                    horizontal:
                                                                        3,
                                                                  ),
                                                              decoration: BoxDecoration(
                                                                border: Border.all(
                                                                  color: Color(
                                                                    0XFF0F172B,
                                                                  ),
                                                                ),
                                                                borderRadius:
                                                                    BorderRadius.circular(
                                                                      3,
                                                                    ),
                                                              ),
                                                              child: Text(
                                                                '设为置顶',
                                                                style: TextStyle(
                                                                  fontSize: 11,
                                                                  color: Color(
                                                                    0XFF0F172B,
                                                                  ),
                                                                ),
                                                              ),
                                                            ),
                                                          )
                                                          : item.value['up'] ==
                                                              1
                                                          ? Container(
                                                            margin:
                                                                EdgeInsets.only(
                                                                  left: 10,
                                                                ),
                                                            padding:
                                                                EdgeInsets.symmetric(
                                                                  horizontal: 3,
                                                                ),
                                                            decoration: BoxDecoration(
                                                              border: Border.all(
                                                                color: Color(
                                                                  0XFF999999,
                                                                ),
                                                              ),
                                                              borderRadius:
                                                                  BorderRadius.circular(
                                                                    3,
                                                                  ),
                                                            ),
                                                            child: Text(
                                                              '已置顶',
                                                              style: TextStyle(
                                                                fontSize: 11,
                                                                color: Color(
                                                                  0XFF999999,
                                                                ),
                                                              ),
                                                            ),
                                                          )
                                                          : SizedBox(),
                                                    ],
                                                  ),
                                                ],
                                              ),
                                              Column(
                                                crossAxisAlignment:
                                                    CrossAxisAlignment.end,
                                                mainAxisAlignment:
                                                    MainAxisAlignment.center,
                                                children: [
                                                  Row(
                                                    children: [
                                                      Text(
                                                        '￥',
                                                        style: TextStyle(
                                                          fontSize: 11,
                                                          color: Color(
                                                            0XFF0F172B,
                                                          ),
                                                        ),
                                                      ),
                                                      Text(
                                                        '${item.value['money_price']}',
                                                        style: TextStyle(
                                                          fontSize: 16,
                                                          color: Color(
                                                            0XFF0F172B,
                                                          ),
                                                          fontWeight:
                                                              FontWeight.bold,
                                                        ),
                                                      ),
                                                    ],
                                                  ),
                                                  SizedBox(height: 10),

                                                  Text(
                                                    '总价￥${item.value['allskutotal']}',
                                                    style: TextStyle(
                                                      fontSize: 12,
                                                      color: Color(0XFF0F172B),
                                                      fontWeight:
                                                          FontWeight.bold,
                                                    ),
                                                  ),
                                                ],
                                              ),
                                            ],
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                            ],
                          )
                          : Column(
                            children: [
                              if (list.isEmpty)
                                Container(
                                  margin: EdgeInsets.only(top: 40),
                                  child: Text(
                                    '暂无竞价订单',
                                    style: TextStyle(
                                      fontSize: 16,
                                      color: Color(0XFF999999),
                                    ),
                                  ),
                                ),
                              for (var item in list.asMap().entries)
                                Container(
                                  margin: EdgeInsets.only(
                                    left: 15,
                                    right: 15,
                                    bottom: 15,
                                  ),
                                  padding: EdgeInsets.symmetric(
                                    horizontal: 15,
                                    vertical: 10,
                                  ),
                                  decoration: BoxDecoration(
                                    color: Color(0XFFF8F9FD),
                                    borderRadius: BorderRadius.circular(10),
                                  ),
                                  child: Row(
                                    children: [
                                      Text(
                                        '${item.key + 1}',
                                        style: TextStyle(
                                          fontSize: 16,
                                          color:
                                              item.key == 0
                                                  ? Color(0XFFF06611)
                                                  : item.key == 1
                                                  ? Color(0XFF999999)
                                                  : item.key == 2
                                                  ? Color(0XFFF6BD69)
                                                  : Color(0Xff333333),
                                          fontWeight: FontWeight.bold,
                                        ),
                                      ),
                                      SizedBox(width: 10),
                                      Text('${item.value['title']}'),
                                      SizedBox(width: 6),
                                      Container(
                                        padding: EdgeInsets.symmetric(
                                          horizontal: 3,
                                        ),
                                        decoration: BoxDecoration(
                                          borderRadius: BorderRadius.circular(
                                            3,
                                          ),
                                          color: Color(0XFF0F172B),
                                        ),
                                        child: Text(
                                          '汇',
                                          style: TextStyle(
                                            fontSize: 9,
                                            color: Color(0XFFFFFFFF),
                                          ),
                                        ),
                                      ),
                                      SizedBox(width: 6),
                                      if (item.value['is_my'] == true)
                                        Container(
                                          padding: EdgeInsets.symmetric(
                                            horizontal: 3,
                                          ),
                                          decoration: BoxDecoration(
                                            borderRadius: BorderRadius.circular(
                                              3,
                                            ),
                                            color: Color(0XFF542AFF),
                                          ),
                                          child: Text(
                                            '我的',
                                            style: TextStyle(
                                              fontSize: 9,
                                              color: Color(0XFFFFFFFF),
                                            ),
                                          ),
                                        ),
                                      Expanded(child: SizedBox()),
                                      Text(
                                        '￥',
                                        style: TextStyle(
                                          fontSize: 11,
                                          color: Color(0XFF0F172B),
                                        ),
                                      ),
                                      Text(
                                        '${item.value['money_price']}',
                                        style: TextStyle(
                                          fontSize: 16,
                                          color: Color(0XFF0F172B),
                                          fontWeight: FontWeight.bold,
                                        ),
                                      ),
                                    ],
                                  ),
                                ),
                            ],
                          ),
                ),
              ],
            ),
          ),
          Obx(
            () =>
                _index.value == 0 && list.isNotEmpty
                    ? Container(
                      margin: EdgeInsets.symmetric(horizontal: 15),
                      color: Color(0XFFFFFFFF),
                      padding: EdgeInsets.symmetric(vertical: 10),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          GestureDetector(
                            onTap:
                                () => {
                                  Get.bottomSheet(
                                    Container(
                                      height: 300,
                                      padding: EdgeInsets.symmetric(
                                        horizontal: 15,
                                      ),
                                      child: Column(
                                        children: [
                                          SizedBox(height: 20),
                                          Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.spaceBetween,
                                            children: [
                                              Text(
                                                '批量下单',
                                                style: TextStyle(
                                                  fontSize: 20,
                                                  color: Color(0XFF0F172B),
                                                ),
                                              ),
                                              GestureDetector(
                                                onTap: () {
                                                  Get.back();
                                                },
                                                child: Image.asset(
                                                  'static/close.png',
                                                  width: 18,
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              ),
                                            ],
                                          ),
                                          SizedBox(height: 30),
                                          Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.spaceBetween,
                                            children: [
                                              Text(
                                                '限价',
                                                style: TextStyle(
                                                  fontSize: 14,
                                                  color: Color(0XFF999999),
                                                ),
                                              ),
                                              Expanded(
                                                child: TextField(
                                                  controller: _controller,
                                                  textAlign: TextAlign.end,
                                                  style: TextStyle(
                                                    fontSize: 12,
                                                  ),
                                                  decoration: InputDecoration(
                                                    isCollapsed: true, //设置高度
                                                    contentPadding:
                                                        EdgeInsets.all(15),
                                                    // contentPadding: EdgeInsets.zero,  // 去掉内边距
                                                    hintStyle: TextStyle(
                                                      color: Color(0xff999999),
                                                    ),
                                                    border:
                                                        InputBorder
                                                            .none, // 隐藏输入框默认边框
                                                    hintText: '输入价格', // 提示文本
                                                  ),
                                                ),
                                              ),
                                              // Text('99',
                                              //     style: TextStyle(
                                              //         fontSize: 16,
                                              //         color: Color(0XFF0F172B))),
                                              Text(
                                                '元',
                                                style: TextStyle(
                                                  fontSize: 14,
                                                  color: Color(0XFF0F172B),
                                                ),
                                              ),
                                            ],
                                          ),
                                          SizedBox(height: 30),
                                          Row(
                                            children: [
                                              Text(
                                                '数量',
                                                style: TextStyle(
                                                  fontSize: 14,
                                                  color: Color(0XFF999999),
                                                ),
                                              ),
                                              Expanded(child: SizedBox()),
                                              GestureDetector(
                                                onTap: () {
                                                  if (num.value > 1) {
                                                    num.value--;
                                                  }
                                                },
                                                child: Image.asset(
                                                  'static/web/jian.png',
                                                  width: 18,
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              ),
                                              SizedBox(width: 20),
                                              Obx(
                                                () => Text(
                                                  '$num',
                                                  style: TextStyle(
                                                    fontSize: 16,
                                                  ),
                                                ),
                                              ),
                                              SizedBox(width: 20),
                                              GestureDetector(
                                                onTap: () {
                                                  num.value++;
                                                },
                                                child: Image.asset(
                                                  'static/web/jia.png',
                                                  width: 18,
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              ),
                                              //
                                            ],
                                          ),
                                          SizedBox(height: 50),
                                          GestureDetector(
                                            onTap: () {
                                              if (_controller.text.isEmpty) {
                                                showTost('请输入价格');
                                              } else {
                                                postData(
                                                  url: '/resale/multiBuy',
                                                  data: {
                                                    "num": '$num',
                                                    "product_id": '$id',
                                                    "max": _controller.text,
                                                    "url":
                                                        'back.html?app=1&web=back',
                                                  },
                                                ).then((res) {
                                                  if (res != null) {
                                                    showTost('正在锁单中...');
                                                    goTimer(res['number']);
                                                  }
                                                });
                                              }
                                            },
                                            child: Container(
                                              decoration: BoxDecoration(
                                                color: Color(0XFF0F172B),
                                                borderRadius:
                                                    BorderRadius.circular(50),
                                              ),
                                              height: 50,
                                              alignment: Alignment.center,
                                              child: Text(
                                                '批量下单',
                                                style: TextStyle(
                                                  fontSize: 16,
                                                  color: Color(0XFFFFFFFF),
                                                ),
                                              ),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                    shape: RoundedRectangleBorder(
                                      // 圆角设置:ml-citation{ref="7" data="citationList"}
                                      borderRadius: BorderRadius.vertical(
                                        top: Radius.circular(15),
                                      ),
                                    ),
                                    backgroundColor: Colors.white,
                                  ),
                                },
                            child: Container(
                              width: 160,
                              alignment: Alignment.center,
                              height: 50,
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(50),
                                color: Color(0XFF542AFF),
                              ),
                              child: Text(
                                '批量下单',
                                style: TextStyle(
                                  fontSize: 15,
                                  color: Color(0XFFFFFFFF),
                                ),
                              ),
                            ),
                          ),
                          GestureDetector(
                            onTap: () {
                              postData(
                                url: '/resale/quickBuy',
                                data: {
                                  "product_id": '$id',
                                  "url": 'back.html?app=1&web=back',
                                },
                              ).then((res) {
                                if (res != null) {
                                  showTost('正在锁单中...');
                                  goTimer(res['number']);
                                }
                              });
                            },
                            child: Container(
                              width: 160,
                              alignment: Alignment.center,
                              height: 50,
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(50),
                                color: Color(0XFF0F172B),
                              ),
                              child: Text(
                                '快捷下单',
                                style: TextStyle(
                                  fontSize: 15,
                                  color: Color(0XFFFFFFFF),
                                ),
                              ),
                            ),
                          ),
                        ],
                      ),
                    )
                    : _index.value == 1
                    ?
                    //委托
                    Container(
                      margin: EdgeInsets.symmetric(horizontal: 15),
                      color: Color(0XFFFFFFFF),
                      padding: EdgeInsets.symmetric(vertical: 10),
                      child: GestureDetector(
                        onTap:
                            () => {
                              Get.bottomSheet(
                                ListView(
                                  children: [
                                    Container(
                                      height: 350,
                                      padding: EdgeInsets.symmetric(
                                        horizontal: 15,
                                      ),
                                      child: Column(
                                        children: [
                                          SizedBox(height: 20),
                                          Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.spaceBetween,
                                            children: [
                                              Text(
                                                '委托',
                                                style: TextStyle(
                                                  fontSize: 20,
                                                  color: Color(0XFF0F172B),
                                                ),
                                              ),
                                              GestureDetector(
                                                onTap: () {
                                                  Get.back();
                                                },
                                                child: Image.asset(
                                                  'static/close.png',
                                                  width: 18,
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              ),
                                            ],
                                          ),
                                          SizedBox(height: 30),
                                          Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.spaceBetween,
                                            children: [
                                              Text(
                                                '委托价格',
                                                style: TextStyle(
                                                  fontSize: 14,
                                                  color: Color(0XFF999999),
                                                ),
                                              ),
                                              Expanded(child: SizedBox()),
                                              Container(
                                                width: 100,
                                                child: TextField(
                                                  controller: controller,
                                                  textAlign: TextAlign.right,
                                                  style: TextStyle(
                                                    fontSize: 12,
                                                  ),
                                                  decoration: InputDecoration(
                                                    isCollapsed: true, //设置高度
                                                    contentPadding:
                                                        EdgeInsets.all(15),
                                                    hintStyle: TextStyle(
                                                      color: Color(0xff999999),
                                                    ),
                                                    border:
                                                        InputBorder
                                                            .none, // 隐藏输入框默认边框
                                                    hintText: '0.00', // 提示文本
                                                  ),
                                                ),
                                              ),
                                              Text(
                                                '元',
                                                style: TextStyle(
                                                  fontSize: 14,
                                                  color: Color(0XFF0F172B),
                                                ),
                                              ),
                                            ],
                                          ),
                                          SizedBox(height: 30),
                                          Row(
                                            children: [
                                              Text(
                                                '数量',
                                                style: TextStyle(
                                                  fontSize: 14,
                                                  color: Color(0XFF999999),
                                                ),
                                              ),
                                              Expanded(child: SizedBox()),
                                              GestureDetector(
                                                onTap: () {
                                                  if (wnum.value > 1) {
                                                    wnum.value--;
                                                  }
                                                },
                                                child: Image.asset(
                                                  'static/web/jian.png',
                                                  width: 18,
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              ),
                                              SizedBox(width: 20),
                                              Obx(
                                                () => Text(
                                                  '$wnum',
                                                  style: TextStyle(
                                                    fontSize: 16,
                                                  ),
                                                ),
                                              ),
                                              SizedBox(width: 20),

                                              GestureDetector(
                                                onTap: () {
                                                  wnum.value++;
                                                },
                                                child: Image.asset(
                                                  'static/web/jia.png',
                                                  width: 18,
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              ),
                                              //
                                            ],
                                          ),
                                          SizedBox(height: 30),
                                          Row(
                                            mainAxisAlignment:
                                                MainAxisAlignment.spaceBetween,
                                            children: [
                                              Text(
                                                '委托消耗',
                                                style: TextStyle(
                                                  fontSize: 14,
                                                  color: Color(0XFF999999),
                                                ),
                                              ),
                                              Obx(
                                                () =>
                                                    info['want_consume_num'] ==
                                                            0
                                                        ? Text(
                                                          '无需消耗',
                                                          style: TextStyle(
                                                            fontSize: 14,
                                                            color: Color(
                                                              0XFF0F172B,
                                                            ),
                                                          ),
                                                        )
                                                        : Text(
                                                          '${info['want_consume_title']} * ${info['want_consume_num']}',
                                                          style: TextStyle(
                                                            fontSize: 14,
                                                            color: Color(
                                                              0XFF0F172B,
                                                            ),
                                                          ),
                                                        ),
                                              ),
                                            ],
                                          ),
                                          SizedBox(height: 50),
                                          GestureDetector(
                                            onTap:
                                                () => {
                                                  postData(
                                                    url: '/makeWant',
                                                    data: {
                                                      "money_price":
                                                          controller.text,
                                                      "num": '$wnum',
                                                      "product_id": '$id',
                                                      "url":
                                                          "back.html?app=1&web=back",
                                                    },
                                                  ).then((res) {
                                                    if (res != null) {
                                                      if (kIsWeb) {
                                                        final uur = Uri.parse(
                                                          '${res['order']['pay_url']}',
                                                        );
                                                        launchUrl(
                                                          uur,
                                                          webOnlyWindowName:
                                                              '_self',
                                                        );
                                                      } else {
                                                        toNamed(
                                                          '/webview?url=${res['order']['pay_url']}&app=1&back=weitou&id=${res['order']['id']}',
                                                        );
                                                      }
                                                    }
                                                  }),
                                                },
                                            child: Container(
                                              decoration: BoxDecoration(
                                                color: Color(0XFF0F172B),
                                                borderRadius:
                                                    BorderRadius.circular(50),
                                              ),
                                              height: 50,
                                              alignment: Alignment.center,
                                              child: Text(
                                                '立即委托',
                                                style: TextStyle(
                                                  fontSize: 16,
                                                  color: Color(0XFFFFFFFF),
                                                ),
                                              ),
                                            ),
                                          ),
                                        ],
                                      ),
                                    ),
                                  ],
                                ),
                                shape: RoundedRectangleBorder(
                                  // 圆角设置:ml-citation{ref="7" data="citationList"}
                                  borderRadius: BorderRadius.vertical(
                                    top: Radius.circular(15),
                                  ),
                                ),
                                backgroundColor: Colors.white,
                              ),
                            },
                        child: Container(
                          alignment: Alignment.center,
                          height: 50,
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(50),
                            color: Color(0XFF0F172B),
                          ),
                          child: Text(
                            '发起委托',
                            style: TextStyle(
                              fontSize: 15,
                              color: Color(0XFFFFFFFF),
                            ),
                          ),
                        ),
                      ),
                    )
                    : _index.value == 2
                    ? Container(
                      margin: EdgeInsets.symmetric(horizontal: 15),
                      color: Color(0XFFFFFFFF),
                      padding: EdgeInsets.symmetric(vertical: 10),
                      child: Row(
                        mainAxisAlignment: MainAxisAlignment.spaceBetween,
                        children: [
                          GestureDetector(
                            onTap: () {
                              getData(
                                url: '/packages/sku_list',
                                data: {
                                  "product_id": '$id',
                                  "per_page": "999",
                                  'page': '1',
                                },
                              ).then((res) {
                                resList.value = res['list'];
                                tindex.value = -1;
                                selItem.value = {};
                                Get.bottomSheet(
                                  isScrollControlled: true,
                                  Container(
                                    height: 500,
                                    padding: EdgeInsets.symmetric(
                                      horizontal: 15,
                                    ),
                                    child: Column(
                                      children: [
                                        SizedBox(height: 20),
                                        Row(
                                          mainAxisAlignment:
                                              MainAxisAlignment.spaceBetween,
                                          children: [
                                            Column(
                                              crossAxisAlignment:
                                                  CrossAxisAlignment.start,
                                              children: [
                                                Text(
                                                  '目前最高竞价',
                                                  style: TextStyle(
                                                    fontSize: 14,
                                                    color: Color(0XFF999999),
                                                  ),
                                                ),
                                                Row(
                                                  children: [
                                                    Text(
                                                      '￥',
                                                      style: TextStyle(
                                                        fontSize: 15,
                                                        color: Color(
                                                          0XFF0F172B,
                                                        ),
                                                      ),
                                                    ),
                                                    Text(
                                                      '${info['examine_max_ratio'] / 100}',
                                                      style: TextStyle(
                                                        fontSize: 23,
                                                        color: Color(
                                                          0XFF0F172B,
                                                        ),
                                                        fontWeight:
                                                            FontWeight.bold,
                                                      ),
                                                    ),
                                                  ],
                                                ),
                                              ],
                                            ),
                                            GestureDetector(
                                              onTap: () {
                                                Get.back();
                                              },
                                              child: Image.asset(
                                                'static/close.png',
                                                width: 18,
                                                fit: BoxFit.fitWidth,
                                              ),
                                            ),
                                          ],
                                        ),
                                        Divider(
                                          color: Color(0XFFDDDDDD),
                                          height: 30,
                                        ),

                                        Row(
                                          children: [
                                            Text(
                                              '${info['title']}',
                                              style: TextStyle(
                                                fontSize: 16,
                                                color: Color(0XFF0F172B),
                                              ),
                                            ),
                                            Text(
                                              '(共${res['list'].length}份)',
                                              style: TextStyle(
                                                fontSize: 14,
                                                color: Color(0XFF999999),
                                              ),
                                            ),
                                          ],
                                        ),
                                        Expanded(
                                          child: ListView(
                                            padding: EdgeInsets.symmetric(
                                              vertical: 15,
                                            ),
                                            children: [Lises(itemWidth)],
                                          ),
                                        ),
                                        GestureDetector(
                                          onTap: () {
                                            if (selItem.isNotEmpty) {
                                              Get.back();
                                              Get.dialog(
                                                AlertDialog(
                                                  backgroundColor:
                                                      Colors.transparent,
                                                  shape: RoundedRectangleBorder(
                                                    borderRadius:
                                                        BorderRadius.circular(
                                                          5,
                                                        ),
                                                  ),
                                                  content: Stack(
                                                    children: [
                                                      Image.asset(
                                                        'static/tan.png',
                                                        width: 255,
                                                        fit: BoxFit.fitWidth,
                                                      ),
                                                      Positioned(
                                                        top: 50,
                                                        right: 0,
                                                        left: 0,
                                                        child: Column(
                                                          children: [
                                                            SizedBox(
                                                              height: 30,
                                                            ),
                                                            Text(
                                                              '请输入交易密码',
                                                              style: TextStyle(
                                                                fontSize: 24,
                                                                color: Color(
                                                                  0XFF0F172B,
                                                                ),
                                                              ),
                                                            ),
                                                            SizedBox(
                                                              height: 30,
                                                            ),
                                                            Container(
                                                              margin:
                                                                  EdgeInsets.symmetric(
                                                                    horizontal:
                                                                        30,
                                                                  ),
                                                              decoration:
                                                                  BoxDecoration(
                                                                    color: Color(
                                                                      0XFFF8F9FD,
                                                                    ),
                                                                    borderRadius:
                                                                        BorderRadius.circular(
                                                                          10,
                                                                        ),
                                                                  ),
                                                              child: TextField(
                                                                obscureText:
                                                                    true,
                                                                controller:
                                                                    controller2,
                                                                style:
                                                                    TextStyle(
                                                                      fontSize:
                                                                          15,
                                                                    ),
                                                                decoration: InputDecoration(
                                                                  isCollapsed:
                                                                      true, //设置高度
                                                                  contentPadding:
                                                                      EdgeInsets.all(
                                                                        15,
                                                                      ),
                                                                  hintStyle: TextStyle(
                                                                    color: Color(
                                                                      0xff999999,
                                                                    ),
                                                                  ),
                                                                  border:
                                                                      InputBorder
                                                                          .none, // 隐藏输入框默认边框
                                                                  hintText:
                                                                      '输入交易密码', // 提示文本
                                                                ),
                                                              ),
                                                            ),
                                                            SizedBox(
                                                              height: 30,
                                                            ),
                                                            GestureDetector(
                                                              onTap: () {
                                                                if (controller2
                                                                    .text
                                                                    .isNotEmpty) {
                                                                  postData(
                                                                    url:
                                                                        '/bidding/getBidding',
                                                                    data: {
                                                                      "product_id":
                                                                          '$id',
                                                                      "bidding_id":
                                                                          "${list[0]['id']}",
                                                                      "level2password":
                                                                          controller2
                                                                              .text,
                                                                      "package_sku_id":
                                                                          "${selItem['id']}",
                                                                    },
                                                                  ).then((res) {
                                                                    if (res !=
                                                                        null) {
                                                                      Get.back();
                                                                      showTost(
                                                                        '出售成功',
                                                                      );
                                                                      Timer(
                                                                        Duration(
                                                                          milliseconds:
                                                                              1000,
                                                                        ),
                                                                        () {
                                                                          list.value =
                                                                              [];
                                                                          getList(
                                                                            '/market/bidding',
                                                                          );
                                                                        },
                                                                      );
                                                                    }
                                                                  });
                                                                } else {
                                                                  showTost(
                                                                    '输入交易密码',
                                                                  );
                                                                }
                                                              },
                                                              child: Container(
                                                                width: 210,
                                                                height: 45,
                                                                decoration: BoxDecoration(
                                                                  color: Color(
                                                                    0XFF0F172B,
                                                                  ),
                                                                  borderRadius:
                                                                      BorderRadius.circular(
                                                                        45,
                                                                      ),
                                                                ),
                                                                alignment:
                                                                    Alignment
                                                                        .center,
                                                                child: Text(
                                                                  '确认',
                                                                  style: TextStyle(
                                                                    fontSize:
                                                                        18,
                                                                    color: Color(
                                                                      0XFFFFFFFF,
                                                                    ),
                                                                  ),
                                                                ),
                                                              ),
                                                            ),
                                                            SizedBox(
                                                              height: 20,
                                                            ),
                                                            GestureDetector(
                                                              onTap: () {
                                                                Get.back();
                                                              },
                                                              child: Text(
                                                                '取消',
                                                                style: TextStyle(
                                                                  fontSize: 18,
                                                                  color: Color(
                                                                    0XFF0F172B,
                                                                  ),
                                                                ),
                                                              ),
                                                            ),
                                                          ],
                                                        ),
                                                      ),
                                                    ],
                                                  ),
                                                ),
                                              );
                                            } else {
                                              showTost('选择一个');
                                            }
                                          },
                                          child: Container(
                                            margin: EdgeInsets.symmetric(
                                              vertical: 10,
                                            ),
                                            decoration: BoxDecoration(
                                              color: Color(0XFF0F172B),
                                              borderRadius:
                                                  BorderRadius.circular(50),
                                            ),
                                            height: 50,
                                            alignment: Alignment.center,
                                            child: Text(
                                              '立即出售',
                                              style: TextStyle(
                                                fontSize: 16,
                                                color: Color(0XFFFFFFFF),
                                              ),
                                            ),
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                  shape: RoundedRectangleBorder(
                                    // 圆角设置:ml-citation{ref="7" data="citationList"}
                                    borderRadius: BorderRadius.vertical(
                                      top: Radius.circular(15),
                                    ),
                                  ),
                                  backgroundColor: Colors.white,
                                );
                              });
                            },
                            child: Container(
                              width: 160,
                              alignment: Alignment.center,
                              height: 50,
                              decoration: BoxDecoration(
                                borderRadius: BorderRadius.circular(50),
                                color: Color(0XFF542AFF),
                              ),
                              child: Text(
                                '我要出售',
                                style: TextStyle(
                                  fontSize: 15,
                                  color: Color(0XFFFFFFFF),
                                ),
                              ),
                            ),
                          ),
                          if (info['my_bidding_id'] == 0)
                            GestureDetector(
                              onTap:
                                  () => {
                                    Get.bottomSheet(
                                      Container(
                                        height: 250,
                                        padding: EdgeInsets.symmetric(
                                          horizontal: 15,
                                        ),
                                        child: Column(
                                          children: [
                                            SizedBox(height: 20),
                                            Row(
                                              mainAxisAlignment:
                                                  MainAxisAlignment
                                                      .spaceBetween,
                                              children: [
                                                Text(
                                                  '竞价',
                                                  style: TextStyle(
                                                    fontSize: 20,
                                                    color: Color(0XFF0F172B),
                                                  ),
                                                ),
                                                GestureDetector(
                                                  onTap: () {
                                                    Get.back();
                                                  },
                                                  child: Image.asset(
                                                    'static/close.png',
                                                    width: 18,
                                                    fit: BoxFit.fitWidth,
                                                  ),
                                                ),
                                              ],
                                            ),
                                            SizedBox(height: 30),
                                            Row(
                                              mainAxisAlignment:
                                                  MainAxisAlignment
                                                      .spaceBetween,
                                              children: [
                                                Text(
                                                  '竞价价格',
                                                  style: TextStyle(
                                                    fontSize: 14,
                                                    color: Color(0XFF999999),
                                                  ),
                                                ),
                                                Expanded(child: SizedBox()),
                                                Container(
                                                  width: 100,
                                                  child: TextField(
                                                    controller: controller1,
                                                    textAlign: TextAlign.right,
                                                    style: TextStyle(
                                                      fontSize: 12,
                                                    ),
                                                    decoration: InputDecoration(
                                                      isCollapsed: true, //设置高度
                                                      contentPadding:
                                                          EdgeInsets.all(15),
                                                      hintStyle: TextStyle(
                                                        color: Color(
                                                          0xff999999,
                                                        ),
                                                      ),
                                                      border:
                                                          InputBorder
                                                              .none, // 隐藏输入框默认边框
                                                      hintText: '0.00', // 提示文本
                                                    ),
                                                  ),
                                                ),
                                                Text(
                                                  '元',
                                                  style: TextStyle(
                                                    fontSize: 14,
                                                    color: Color(0XFF0F172B),
                                                  ),
                                                ),
                                              ],
                                            ),
                                            SizedBox(height: 50),
                                            GestureDetector(
                                              onTap:
                                                  () => {
                                                    if (controller1
                                                        .text
                                                        .isNotEmpty)
                                                      {
                                                        postData(
                                                          url: '/makeBidding',
                                                          data: {
                                                            "money_price":
                                                                controller1
                                                                    .text,
                                                            "product_id": "$id",
                                                            "url":
                                                                "back.html?app=1&web=back",
                                                          },
                                                        ).then((res) {
                                                          if (res != null) {
                                                            if (kIsWeb) {
                                                              final uur = Uri.parse(
                                                                '${res['order']['pay_url']}',
                                                              );
                                                              launchUrl(
                                                                uur,
                                                                webOnlyWindowName:
                                                                    '_self',
                                                              );
                                                            } else {
                                                              toNamed(
                                                                '/webview?url=${res['order']['pay_url']}&app=1&back=jingjia',
                                                              );
                                                            }
                                                          }
                                                        }),
                                                      }
                                                    else
                                                      {showTost('输入价格')},
                                                  },
                                              child: Container(
                                                decoration: BoxDecoration(
                                                  color: Color(0XFF0F172B),
                                                  borderRadius:
                                                      BorderRadius.circular(50),
                                                ),
                                                height: 50,
                                                alignment: Alignment.center,
                                                child: Text(
                                                  '立即竞价',
                                                  style: TextStyle(
                                                    fontSize: 16,
                                                    color: Color(0XFFFFFFFF),
                                                  ),
                                                ),
                                              ),
                                            ),
                                          ],
                                        ),
                                      ),
                                      shape: RoundedRectangleBorder(
                                        // 圆角设置:ml-citation{ref="7" data="citationList"}
                                        borderRadius: BorderRadius.vertical(
                                          top: Radius.circular(15),
                                        ),
                                      ),
                                      backgroundColor: Colors.white,
                                    ),
                                  },
                              child: Container(
                                width: 160,
                                alignment: Alignment.center,
                                height: 50,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(50),
                                  color: Color(0XFF0F172B),
                                ),
                                child: Text(
                                  '参与竞价',
                                  style: TextStyle(
                                    fontSize: 15,
                                    color: Color(0XFFFFFFFF),
                                  ),
                                ),
                              ),
                            ),
                          if (info['my_bidding_id'] != 0)
                            GestureDetector(
                              onTap:
                                  () => {
                                    Get.bottomSheet(
                                      Container(
                                        height: 250,
                                        padding: EdgeInsets.symmetric(
                                          horizontal: 15,
                                        ),
                                        child: Column(
                                          children: [
                                            SizedBox(height: 20),
                                            Row(
                                              mainAxisAlignment:
                                                  MainAxisAlignment
                                                      .spaceBetween,
                                              children: [
                                                Text(
                                                  '竞价',
                                                  style: TextStyle(
                                                    fontSize: 20,
                                                    color: Color(0XFF0F172B),
                                                  ),
                                                ),
                                                Image.asset(
                                                  'static/close.png',
                                                  width: 18,
                                                  fit: BoxFit.fitWidth,
                                                ),
                                              ],
                                            ),
                                            SizedBox(height: 30),
                                            Row(
                                              mainAxisAlignment:
                                                  MainAxisAlignment
                                                      .spaceBetween,
                                              children: [
                                                Text(
                                                  '竞价价格',
                                                  style: TextStyle(
                                                    fontSize: 14,
                                                    color: Color(0XFF999999),
                                                  ),
                                                ),
                                                Expanded(child: SizedBox()),
                                                Container(
                                                  width: 100,
                                                  child: TextField(
                                                    controller: controller1,
                                                    textAlign: TextAlign.right,
                                                    style: TextStyle(
                                                      fontSize: 12,
                                                    ),
                                                    decoration: InputDecoration(
                                                      isCollapsed: true, //设置高度
                                                      contentPadding:
                                                          EdgeInsets.all(15),
                                                      hintStyle: TextStyle(
                                                        color: Color(
                                                          0xff999999,
                                                        ),
                                                      ),
                                                      border:
                                                          InputBorder
                                                              .none, // 隐藏输入框默认边框
                                                      hintText: '0.00', // 提示文本
                                                    ),
                                                  ),
                                                ),
                                                Text(
                                                  '元',
                                                  style: TextStyle(
                                                    fontSize: 14,
                                                    color: Color(0XFF0F172B),
                                                  ),
                                                ),
                                              ],
                                            ),
                                            SizedBox(height: 50),
                                            GestureDetector(
                                              onTap:
                                                  () => {
                                                    if (controller1
                                                        .text
                                                        .isNotEmpty)
                                                      {
                                                        postData(
                                                          url: '/makeBidding',
                                                          data: {
                                                            "money_price":
                                                                controller1
                                                                    .text,
                                                            "product_id": "$id",
                                                            "url":
                                                                'back.html?app=1&web=back',
                                                          },
                                                        ).then((res) {
                                                          if (res != null) {
                                                            if (kIsWeb) {
                                                              final uur =
                                                                  Uri.parse(
                                                                    '$res',
                                                                  );
                                                              launchUrl(
                                                                uur,
                                                                webOnlyWindowName:
                                                                    '_self',
                                                              );
                                                            } else {
                                                              toNamed(
                                                                '/webview?url=$res&app=1&back=suu',
                                                              );
                                                            }
                                                          }
                                                        }),
                                                      }
                                                    else
                                                      {showTost('输入价格')},
                                                  },
                                              child: Container(
                                                decoration: BoxDecoration(
                                                  color: Color(0XFF0F172B),
                                                  borderRadius:
                                                      BorderRadius.circular(50),
                                                ),
                                                height: 50,
                                                alignment: Alignment.center,
                                                child: Text(
                                                  '立即竞价',
                                                  style: TextStyle(
                                                    fontSize: 16,
                                                    color: Color(0XFFFFFFFF),
                                                  ),
                                                ),
                                              ),
                                            ),
                                          ],
                                        ),
                                      ),
                                      shape: RoundedRectangleBorder(
                                        // 圆角设置:ml-citation{ref="7" data="citationList"}
                                        borderRadius: BorderRadius.vertical(
                                          top: Radius.circular(15),
                                        ),
                                      ),
                                      backgroundColor: Colors.white,
                                    ),
                                  },
                              child: Container(
                                width: 160,
                                alignment: Alignment.center,
                                height: 50,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.circular(50),
                                  color: Color(0XFF0F172B),
                                ),
                                child: Text(
                                  '取消竞价',
                                  style: TextStyle(
                                    fontSize: 15,
                                    color: Color(0XFFFFFFFF),
                                  ),
                                ),
                              ),
                            ),
                        ],
                      ),
                    )
                    : SizedBox(),
          ),
        ],
      ),
    );
  }
}

Widget Lises(itemWidth, [String? type]) {
  return Wrap(
    alignment: WrapAlignment.spaceBetween,
    children: [
      if (resList.isEmpty)
        Container(
          margin: EdgeInsets.only(top: 50),
          alignment: Alignment.center,
          child: Text('暂无藏品', style: TextStyle(color: Color(0XFF999999))),
        ),
      for (var item in resList.asMap().entries)
        GestureDetector(
          onTap: () {
            if (type == 'nock') {
              return;
            }
            selItem.value = item.value;
            tindex.value = item.key;
          },
          child: Obx(
            () => Container(
              width: 165,
              decoration: BoxDecoration(
                border: Border.all(
                  color:
                      tindex.value == item.key
                          ? Color(0XFF542AFF)
                          : Color(0XFFffffff),
                  width: 2,
                ),
                borderRadius: BorderRadius.circular(10),
                color: Color(0XFFF8F9FD),
              ),
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      ClipRRect(
                        borderRadius: BorderRadius.only(
                          topLeft: Radius.circular(10),
                          bottomLeft: Radius.circular(10),
                        ), // 设置圆角大小
                        child: Image.network(
                          '${info['thumb']}',
                          width: 50,
                          height: 50,
                          fit: BoxFit.fill,
                        ),
                      ),
                      Column(
                        children: [
                          Container(
                            margin: EdgeInsets.only(right: 15),
                            child: Text(
                              '# ${hao('${item.value['nftId']}')}',
                              style: TextStyle(
                                fontSize: 14,
                                color: Color(0XFF0F172B),
                                fontWeight: FontWeight.bold,
                              ),
                            ),
                          ),
                          Text(
                            item.value['status'] == 5 ? '寄售中' : '未寄售',
                            style: TextStyle(
                              fontSize: 12,
                              color: Color(0XFF542AFF),
                            ),
                          ),
                        ],
                      ),

                      // Text(
                      //   '#${Get.find<MyMethod>().hao('${list[index]['']}')}',
                      //   style: TextStyle(
                      //       fontSize: 16,
                      //       color: Color(0XFF0F172B),
                      //       fontWeight: FontWeight.bold),
                      // ),
                      // Container(
                      //   margin: EdgeInsets.only(left: 7),
                      //   padding: EdgeInsets.symmetric(horizontal: 3),
                      //   decoration: BoxDecoration(
                      //       border: Border.all(color: Color(0XFF542AFF)),
                      //       borderRadius: BorderRadius.circular(5)),
                      //   child: Text('寄售中',
                      //       style: TextStyle(
                      //           fontSize: 12, color: Color(0XFF542AFF))),
                      // )
                    ],
                  ),

                  // Text(
                  //   '寄售价：￥3235.33 ',
                  //   style: TextStyle(fontSize: 14, color: Color(0XFF999999)),
                  // ),
                  // Text(
                  //   '寄售价：￥3235.33 ',
                  //   style: TextStyle(fontSize: 14, color: Color(0XFF999999)),
                  // ),
                ],
              ),
            ),
          ),
        ),
    ],
  );

  // Container(
  //   color: Color(0XFFFFFFFF),
  //   child:
  //    GridView.count(
  //     crossAxisCount: 2,
  //     crossAxisSpacing: 12,
  //     mainAxisSpacing: 12,
  //     childAspectRatio: itemWidth / 80,
  //     shrinkWrap: true,
  //     physics: NeverScrollableScrollPhysics(),
  //     children: List.generate(resList.length, (index) {
  //       return GestureDetector(
  //         onTap: () {
  //           tindex.value = index;
  //           selItem.value = resList[index];
  //         },
  //         child:
  //         Obx(()=>

  //         )
  //          ,
  //       );
  //     }),
  //   ),

  // );
}
